//
//  MyFirstScene.cpp
//  XTest
//
//  Created by 100TV protocal on 12-11-12.
//
//

#include "MyFirstScene.h"

using namespace cocos2d;

CCScene* CMyFirstScene::scene()
{
    // 'scene' is an autorelease object
    CCScene *scene = CCScene::create();
    
    // 'layer' is an autorelease object
    CMyFirstScene *layer = CMyFirstScene::create();
    
    // add layer as a child to scene
    scene->addChild(layer);
    
    // return the scene
    return scene;
}


bool CMyFirstScene::init()
{
    if(!CCLayer::init())
    {
        return false;
    }
    // do something
    return true;
}

void CMyFirstScene::onEnter()
{
    // do something
    CCLayer::onEnter();
}

void CMyFirstScene::Show()
{
    // 建立场景和层
    cocos2d::CCScene * pNewScene = CCScene::create();
    CMyFirstScene * pLayer = CMyFirstScene::create();
    pNewScene->addChild(pLayer);
    // 切换场景
    cocos2d::CCScene *pCurScene = cocos2d::CCDirector::sharedDirector()->getRunningScene();
    if(NULL == pCurScene)
    {
        cocos2d::CCDirector::sharedDirector()->runWithScene(pNewScene);
    }
    else
    {
        cocos2d::CCDirector::sharedDirector()->replaceScene(pNewScene);
    }
}